<template>
	<div class="use">
		<!-- <el-dialog title="短信功能开通" :visible.sync="show" :close-on-press-escape="false" :close-on-click-modal="false" width="600px">
		    <div style="color: #606060; margin-bottom: 20px;">
		       为避免乱发短信导致接口失效，根据短信接口要求，群发短信必须 上传相关公司资质，及签署短信服务协议
		    </div>
			<div style="color: #606060; margin-bottom: 20px;">
				请上传公司营业执照
				<el-upload class="avatar-uploader" action="#" :on-change="uploadok" :auto-upload="false" :show-file-list="false">
				  <el-button v-if="!all.permit" size="small" type="primary">点击上传</el-button>
				  <img :src="all.permit" v-if="all.permit" style="width: 100px;">
				</el-upload>
			</div>
			<div style="color: #C5C5C5; margin-bottom: 20px;">
				黑白扫描件盖彩色公司章
			</div>
			<div style="color: #606060; margin-bottom: 20px;">
				请上传短信服务协议照片或扫描件
				<el-upload class="avatar-uploader" action="#" :on-change="uploadok2" :auto-upload="false" :show-file-list="false">
				  <el-button v-if="!all.agree" size="small" type="primary">点击上传</el-button>
				  <img :src="all.agree" v-if="all.agree" style="width: 100px;">
				</el-upload>
			</div>
			<div style="color: #606060;"><span style="color: #3154FF; cursor: pointer;" @click="down">点此下载《短信服务协议》</span>打印签字后盖公司章照片或扫描</div>
		    <span slot="footer" class="dialog-footer">
		      <el-button @click="show = false">取 消</el-button>
		      <el-button type="primary" @click="tianjia">确 定</el-button>
		    </span>
		</el-dialog> -->
    <el-dialog title="短信服务协议" :visible.sync="show" center :close-on-press-escape="false" :close-on-click-modal="false" width="1000px">
       <h3 style="margin-bottom:20px">敢探号短信功能使用范围：</h3>
       <div style="margin-bottom:20px;color:rgb(102, 102, 102); line-height: 30px;">
         <div>敢探号的短信中心短信功能仅用于发送与订单相关的通知类短信，为促进用户完善订单信息，助力订单顺利生产，不可用于其他用途。</div>
         <div>具体禁止的短信内容类型如下：</div>
         <div>1、 引导类短信：引导注册某某网站、关注公众号、下载安装任何APP、发红包、好评返现。</div>
         <div>2、 广告类短信：通过链接或文字描述引导用户前往：免费送XX、抽奖、红包等内容网页。</div>
         <div>3、违法短信：短信内容或跳转链接涉及：赌博、色情、诈骗、恐吓、政治反动等与国家法律法规或政策相违背的内容。 </div>
       </div>
       <h3 style="margin-bottom:20px;">敢探号短信功能使用范围：</h3>
       <div style="margin-bottom:20px;color:rgb(102, 102, 102); line-height: 30px;">
         <div>签署本协议代表您同意以下敢探号运营团队处理措施：</div>
         <div>1、 我们将会对每次群发的短信进行人工审核，这可能需要些时间（请尽量在工作时间发送）。</div>
         <div>2、 如果发送引导类和广告类短信内容，第一次警告，第二次将永久封禁用户短信功能（已
         充值短信不予退回）。</div>
         <div>3、 如果发送违法短信内容：我们将直接冻结店铺账户，同时提交相关公司信息及证据至公安机关。</div>
         <div>因违反约定，被运营商或管理执法部门认定严重违规，愿意承担违约责任，并遵守运营商或管理执法部门相关规定以及处罚决定。</div>
         <div>郑重警告：根据我国相关法律规定，对发送违法短信的企业责任人及相关负责人可依法追究其刑事责任。</div>
         <div>友情提示：短信中如果包含移动、联通、电信、手机卡、流量卡等字样会有很高的概率被拦截（三大运营商端口拦截），对于因发送以上字段被拦截的短信，已扣除的短信余额我们不予退回。</div>
       </div>

        <span slot="footer" center class="dialog-footer">
          <el-button round @click="show = false">取 消</el-button>
          <el-button type="danger" round @click="tianjia">我同意</el-button>
        </span>
    </el-dialog>
	</div>
</template>

<script>
import axios from 'axios'
	export default {

		name: "use",
		data() {
			return {
				all:{
					permit:"",
					agree:""
				},
				use:false,
				show:false,
				url:""
			}
		},
		created() {
			this.getuse()
			//地址配置,用于下载模板
			if(window.location.href.indexOf("91haoka_platform") > -1){
				this.url = window.location.origin+"/91haoka_platform/"
			}else{
				this.url = ""
			}
		},
		mounted() {

		},
		methods: {
			down:function(){
				const a = document.createElement('a');
				a.setAttribute('href', this.url + 'static/moban/duanxinxieyi.docx');
				a.click();
			},
			//获取是否可用
			getuse:function(){
				axios.get('/api/plan-market/message/is_use_sms')
					.then(response => {
						if (response.data.msg.code == 0) {
							if(response.data.data.is_use_sms == 1){
								this.use = true
							}
						} else {
							this.$message.error(response.data.msg.info);
						}
					})
			},
			tianjia:function(){

        axios.get('/api/plan-market/enable/sms')
        	.then(response => {
        		if (response.data.msg.code == 0) {
        			this.$message.success('已开通')
        			this.show = false
              this.getuse()
        		} else {
        			this.$message.error(response.data.msg.info);
        		}
        	})
				// axios.post('/api/plan-market/message/upload/qualifications', this.all)
				// 	.then(response => {
				// 		if (response.data.msg.code == 0) {
				// 			this.$message.success('已上传，请等待审核')
				// 			this.show = false
				// 		} else {
				// 			this.$message.error(response.data.msg.info);
				// 		}
				// 	})
			},
			//单个图片上传
				uploadok: function(file) {

					if(file.raw.type != 'image/jpeg' && file.raw.type != 'image/png' && file.raw.type != 'image/jpg'){
						this.$message.error('只能上传图片');
						return false
					}
					var that = this;
					var formData = new FormData();
					formData.append("pic", file.raw);
					axios.post('/api/plan-market/order-page/upload-pic', formData)
						.then(response => {
							if (response.data.msg.code == 0) {

								if(response.data.data.includes('static.91haoka.cn')){
									that.all.permit = response.data.data
								}else{
									that.all.permit = 'https://static.91haoka.cn/' + response.data.data
								}

							} else {
								that.$message.error(response.data.msg.info);
							}
						})
				},
				//单个图片上传
				uploadok2: function(file) {

					if(file.raw.type != 'image/jpeg' && file.raw.type != 'image/png' && file.raw.type != 'image/jpg'){
						this.$message.error('只能上传图片');
						return false
					}

					var that = this;
					var formData = new FormData();
					formData.append("pic", file.raw);
					axios.post('/api/plan-market/order-page/upload-pic', formData)
						.then(response => {
							if (response.data.msg.code == 0) {
								if(response.data.data.includes('static.91haoka.cn')){
									that.all.agree = response.data.data
								}else{
									that.all.agree = 'https://static.91haoka.cn/' + response.data.data
								}

							} else {
								that.$message.error(response.data.msg.info);
							}
						})
				}

		}
	}
</script>

<style lang="scss" scoped>
	.use{}
</style>
